//
//  StrategyDemo.m
//  设计模式
//
//  Created by huyang on 2020/7/13.
//  Copyright © 2020 test. All rights reserved.
//

#import "StrategyDemo.h"
#import "ActiveContext.h"
#import "ActiveStrategy.h"
#import "ActiveDefalut.h"
#import "ActiveA.h"
#import "ActiveB.h"

@interface StrategyDemo ()
@property (weak, nonatomic) IBOutlet UITextField *num;
@property (weak, nonatomic) IBOutlet UILabel *showLB;

@end

@implementation StrategyDemo

- (void)viewDidLoad {
    [super viewDidLoad];
}
- (IBAction)getMoneyBtn:(UIButton *)sender {
    ActiveContext *context = [ActiveContext new];
    if (_num.text.integerValue == 1) {
        ActiveDefalut *defalut = [ActiveDefalut new];
        CGFloat money = [context initWithContext:defalut];
        self.showLB.text = [NSString stringWithFormat:@"没有活动的时候金额为%.2f元",money];
    } else if (_num.text.integerValue == 2) {
        ActiveA *A = [ActiveA new];
        CGFloat money = [context initWithContext:A];
        self.showLB.text = [NSString stringWithFormat:@"活动A的时候金额为%.2f元",money];
    } else if (_num.text.integerValue == 3) {
       ActiveB *B = [ActiveB new];
       CGFloat money = [context initWithContext:B];
       self.showLB.text = [NSString stringWithFormat:@"活动B的时候金额为%.2f元",money];
    }
    
}



@end
